// 这里放的登录和信息流程

import request from '@/utils/request';

// 发送邮箱验证码
export async function sendEmailCode(params: Login.EmailParams) {
  return request<[]>({
    method: 'get',
    url: '/web/sendEmailCode',
    params,
  });
}
// 获取时间戳

export async function getTimeMillis() {
  return request<{ timestamp: string }>({
    method: 'get',
    url: '/web/getTimeMillis',
  });
}
// 邮箱注册接口
export async function handleRegister(data: Login.LoginParams) {
  return request<[]>({
    method: 'post',
    url: '/web/register',
    data,
  });
}
// 统一登录接口
export async function handleLogin(data: { account: string; password: string; captcha: string }) {
  return request<[]>({
    method: 'post',
    url: '/web/login',
    data,
  });
}

// 获取手机滑动验证码token
export async function getCaptchaToken(data: { mobile: string }) {
  return request<string>({
    method: 'post',
    url: '/web/captcha',
    data,
  });
}

// 获取手机滑动验证码
export async function getCaptcha(data: Login.PhoneParams) {
  return request<string>({
    method: 'post',
    url: '/web/sendMobileCode',
    data,
  });
}
// 获取手机验证码 无token
export async function sendMobileCodeNT(data: { mobile: string } & Record<string, any>) {
  return request<[]>({
    method: 'post',
    url: '/web/sendMobileCodeNT',
    data,
  });
}

// 检查用户是否绑定手机号
export async function checkUserMobile() {
  return request<[]>({
    method: 'get',
    url: '/web/checkUserMobile',
  });
}

// 登录页面的修改密码
export async function handleResetPassword(data: Login.LoginParams) {
  return request<[]>({
    method: 'post',
    url: '/web/resetPassword',
    data,
  });
}
// 修改密码
export async function handleResetPasswordNT(data: { oldPassword: string; newPassword: string }) {
  return request<[]>({
    method: 'post',
    url: '/web/resetPasswordNT',
    data,
  });
}
// 获取用户信息
export async function getUserInfo() {
  return request<Record<string, any>>({
    method: 'get',
    url: '/web/getUserInfo',
  });
}

// 添加手机号/修改手机号

export async function addMobileAuth(data: { mobile: string; captcha: string }) {
  return request<[]>({
    method: 'post',
    url: '/web/addMobileAuth',
    data,
  });
}

export async function changeEmail(data: { email: string; captcha: string }) {
  return request<[]>({
    method: 'post',
    url: '/web/updateEmail',
    data,
  });
}
export async function sendResetCode(data: { account: string; sendType: any }) {
  return request<[]>({
    method: 'post',
    url: '/web/sendResetCode',
    data,
  });
}
export async function registerByMobile(data: { mobile: string; captcha: string }) {
  return request<[]>({
    method: 'post',
    url: '/web/registerByMobile',
    data,
  });
}
export async function loginByMobile(data: { mobile: string; captcha: string }) {
  return request<[]>({
    method: 'post',
    url: '/web/loginByMobile',
    data,
  });
}

export async function loginByEmail(data: { email: string; captcha: string }) {
  return request<[]>({
    method: 'post',
    url: '/web/loginByEmail',
    data,
  });
}
// 获取枚举值

export async function findByCodeList(params: { code: Login.KeyCodeList }) {
  return request<
    Record<
      Login.KeyCodeList,
      {
        builtin: number;
        code: Login.KeyCodeList;
        en_name: string;
        mo_name: string;
        name: string;
        value: string | number;
        id: number;
        parent: number;
      }[]
    >
  >({
    method: 'get',
    url: '/web/findByCodeList',
    params,
  });
}
// 获取国家

export async function getCountry() {
  return request<any>({
    method: 'get',
    url: '/web/getCountry',
  });
}
// 添加信息

export async function handleAddInfo(data: Record<string, any>) {
  return request<[]>({
    method: 'post',
    url: '/web/auth',
    data,
  });
}

// 获取枚举值

export async function findByCodeByParent(params: { parent: number }) {
  return request<
    {
      builtin: number;
      code: Login.KeyCodeList;
      en_name: string;
      mo_name: string;
      name: string;
      value: string | number;
      id: number;
      parent: number;
    }[]
  >({
    method: 'get',
    url: '/web/findByCodeByParent',
    params,
  });
}
// 获取银行流水url
export async function getLinksUrl() {
  return request<{ url: string; customerToken: string }>({
    method: 'get',
    url: '/web/getLinksUrl',
  });
}
// 获取流水信息
export async function getLinksStatements(params: { token: string; code: string }) {
  return request<[]>({
    method: 'get',
    url: '/web/getLinksStatements',
    params,
  });
}
//隐私协议
export async function handlePrivacy(params?: { title: string }) {
  return request<{ content: string }>({
    method: 'get',
    url: '/web/privacy',
    params,
  });
}
// 参数配置
export async function handleParams(params: { code: string }) {
  return request<Record<any, any>>({
    method: 'get',
    url: '/web/getConfig',
    params,
  });
}

// 未读标识
export async function handleUnreadFlag() {
  return request<any>({
    method: 'get',
    url: '/web/unreadFlag',
  });
}

// 首页
export async function getHomeIndex() {
  return request<any>({
    method: 'get',
    url: '/web/index',
  });
}
export async function getMoreIndex(params: {
  type: string;
  institutionType?: number;
  tuFlag?: number;
  appointmentHomeFlag?: number;
}) {
  return request<any>({
    method: 'get',
    url: '/web/indexAll',
    params,
  });
}
// 获取认证步骤
export async function getPositionStep() {
  return request<any>({
    method: 'get',
    url: '/web/getPositionStep',
  });
}
// 获取当前步骤
export async function getCurrentPositionStep() {
  return request<any>({
    method: 'get',
    url: '/web/getStep',
  });
}
// 编辑
export async function editPage(data: Record<string, any>) {
  return request<any>({
    method: 'post',
    url: '/web/edit',
    data,
  });
}
export async function editOrder(data: Record<string, any> & { id: string }) {
  return request<any>({
    method: 'post',
    url: '/web/editOrder',
    data,
  });
}

export async function getOrderInfo() {
  return request<{ additionalCount: number; rewardCount: number }>({
    method: 'get',
    url: '/web/OrderInfo',
  });
}
export async function handleReward(data: { id: string; bank: string; account: string }) {
  return request<string>({
    method: 'post',
    url: '/web/reward',
    data,
  });
}
// type 1 手机 2邮箱
export async function handleCheckRegister(data: { account: string; type: 1 | 2 }) {
  return request<string>({
    method: 'post',
    url: '/web/checkRegister',
    data,
  });
}

export async function handleResiterByContact(data: { mobile: string; captcha: string }) {
  return request<[]>({
    method: 'POST',
    url: '/web/registerModal',
    data,
  });
}
